//package com.imay.live.view.dialog;
//
//import android.content.DialogInterface;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.v4.app.Fragment;
//import android.support.v4.app.FragmentManager;
//import android.support.v4.app.FragmentTransaction;
//import android.view.View;
//import android.view.WindowManager;
//
//import com.imay.base.fragment.BaseDialogFragment;
//import com.imay.live.R;
//import com.imay.live.activity.BaseUserActivity;
//import com.imay.live.fragment.load.LoadMokeyFragment;
//import com.imay.live.fragment.user.MainUserListener;
//import com.imay.live.fragment.user.UserFragment;
//import com.imay.live.manager.AccountManager;
//
///**
// * Created by chan on 2017/8/7 0007.
// */
//
//public class MainDialogFragment extends BaseDialogFragment {
//
//
//    private static MainDialogFragment instance;
//
//    public static MainDialogFragment getInstance() {
//        if (instance == null) {
//            instance = new MainDialogFragment();
//        }
//        return instance;
//    }
//
//    protected int getHeight() {
//        return WindowManager.LayoutParams.MATCH_PARENT;
//    }
//
//    protected boolean isTranslucentStatus() {
//        return true;
//    }
//
//    protected boolean isTranslucentBackground() {
//        return true;
//    }
//
//    /**
//     * 是否填满整个屏幕
//     */
//    protected boolean isMatchParent() {
//        return true;
//    }
//
//    @Override
//    protected int getLayoutId() {
//        return R.layout.fragment_user;
//    }
//
//    @Override
//    protected void initView(Bundle savedInstanceState) {
//        int status = getArguments().getInt(BaseUserActivity.SHOW_START_STATUS_KEY);
//        if (status == BaseUserActivity.OPEN_START_FRAGMENT) {
//            addFragment(LoadMokeyFragment.getInstance());
//        } else if (status == BaseUserActivity.OPEN_USER_FRAGMENT) {
//            addFragment(UserFragment.getInstance());
//        }
//    }
//
//    @Override
//    public void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//    }
//
//    @Override
//    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//        super.onViewCreated(view, savedInstanceState);
//    }
//
//    /**
//     * loading界面
//     *
//     * @param loadFragment
//     */
//    private void addFragment(Fragment loadFragment) {
//        FragmentManager fragmentManager = getChildFragmentManager();
//        FragmentTransaction transaction = fragmentManager.beginTransaction();
//        Fragment fragment = fragmentManager.findFragmentByTag(MainDialogFragment.class.toString());
//        if (fragment == null) {
//            transaction.add(R.id.user_content, loadFragment, MainDialogFragment.class.toString());
//            transaction.show(loadFragment);
//        } else {
//            transaction.remove(fragment);
//            transaction.add(R.id.user_content, loadFragment, MainDialogFragment.class.toString());
//            transaction.show(loadFragment);
//        }
//        transaction.commitAllowingStateLoss();
//    }
//
//    /**
//     * 切换登录或者其他
//     *
//     * @param loadFragment
//     */
//    public void openFragment(Fragment loadFragment) {
//        FragmentManager fragmentManager = getChildFragmentManager();
//        FragmentTransaction transaction = fragmentManager.beginTransaction();
//        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
//        Fragment fragment = fragmentManager.findFragmentByTag(MainDialogFragment.class.toString());
//        if (fragment == null) {
//            transaction.add(R.id.user_content, loadFragment, MainDialogFragment.class.toString());
//            transaction.show(loadFragment);
//        } else {
//            transaction.replace(R.id.user_content, loadFragment, MainDialogFragment.class.toString());
//            transaction.show(loadFragment);
//        }
//        transaction.commitAllowingStateLoss();
//    }
//
//
//    @Override
//    public void onDismiss(DialogInterface dialog) {
//        if (AccountManager.getInstance().isLogined()) {
//            if (getActivity() instanceof MainUserListener) {
//                ((MainUserListener) getActivity()).loadData();
//            }
//        } else {
//            if (getActivity() instanceof MainUserListener) {
//                ((MainUserListener) getActivity()).noLogin();
//            }
//        }
//        super.onDismiss(dialog);
//    }
//
//    @Override
//    public void onCancel(DialogInterface dialog) {
//        if (AccountManager.getInstance().isLogined()) {
//            if (getActivity() instanceof MainUserListener) {
//                ((MainUserListener) getActivity()).loadData();
//            }
//        } else {
//            if (getActivity() instanceof MainUserListener) {
//                ((MainUserListener) getActivity()).noLogin();
//            }
//        }
//        super.onCancel(dialog);
//    }
//}
